package com.platform.common.authentication.repository.impl;

import com.platform.common.authentication.entity.enums.UserTokenRedisEnum;
import com.platform.common.authentication.repository.TokenRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;

import java.text.MessageFormat;

public class RedisTokenRepositoryImpl implements TokenRepository {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public String getAccessToken(String id) throws Exception {
        String accessKey = MessageFormat.format(UserTokenRedisEnum.TOKEN_ACCESS_KEY.getCode(), id);
        return stringRedisTemplate.opsForValue().get(accessKey);
    }

}
